package com.ebpm.designer.dir
{
	import com.ebpm.designer.NodeContainer;
	import com.ebpm.designer.WF;
	import com.ebpm.designer.WP;
	
	import flash.events.MouseEvent;
	
	import mx.containers.Canvas;
	import mx.controls.Image;
	
	import spark.components.Group;
	import spark.primitives.BitmapImage;
	
	//nodeContianer右下角的 拖拽框
	public class NodeContainerRDDir extends Canvas
	{
		[Embed(source="img/nw.png")]
		private static const cursorIcon:Class;
		
		public var iconImage:Image;
		public var nodeContainer:NodeContainer;
		public function NodeContainerRDDir(container:NodeContainer)
		{
			this.nodeContainer = container;
			this.initIcon();
			this.initStyle();
			this.addEventListener(MouseEvent.MOUSE_OVER, _mouseOver);
			this.addEventListener(MouseEvent.MOUSE_OUT, _mouseOut);
			this.addEventListener(MouseEvent.MOUSE_DOWN, _mouseDown);
			this.addEventListener(MouseEvent.MOUSE_UP, _mouseUp);
		}
		
		
		private function initIcon():void
		{
			var titleIcon:Canvas = new Canvas();
			titleIcon.x = 0;
			titleIcon.y = 0;
			titleIcon.width = WF.ITEM_SIZE;
			titleIcon.height = WF.ITEM_SIZE;
			
			var group:Group = new Group();
			var bi:BitmapImage = new BitmapImage();
			bi.source = WF.Icon_RD_Resize;
			bi.width = titleIcon.width;
			bi.height = titleIcon.height;
			group.addElement(bi);
			titleIcon.addElement(group);
			this.addElement(titleIcon);
		}
		
		public function initStyle():void {
			this.x = this.nodeContainer.width - WF.ITEM_SIZE;
			this.y = this.nodeContainer.height - WF.ITEM_SIZE;
			this.width = WF.ITEM_SIZE;
			this.height = WF.ITEM_SIZE;
		}
		
		public function _mouseOver(event:MouseEvent):void
		{
			this.cursorManager.setCursor(cursorIcon);
		}
		
		public function _mouseOut(event:MouseEvent):void
		{
			this.cursorManager.removeAllCursors();
		}
		
		
		public function _mouseDown(event:MouseEvent):void
		{
//			this.nodeContainer.workPanel.mouseStartX = event.stageX;
//			this.nodeContainer.workPanel.mouseStartY = event.stageY;
			this.nodeContainer.resizeStartW = this.nodeContainer.width;
			this.nodeContainer.resizeStartH = this.nodeContainer.height;

			WP.isAllowSelectNodeContainers = false;
			this.nodeContainer.isResizing = true;
			this.nodeContainer.dirType = 2;
		}
		
		public function _mouseUp(event:MouseEvent):void
		{
			this.nodeContainer.isResizing = false;
		}
		
		public function resizingByParent():void {
			this.x = this.nodeContainer.width - WF.ITEM_SIZE;
			this.y = this.nodeContainer.height - WF.ITEM_SIZE;
		}
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
	}
}